package com.atguigu.srb.mybatis.controller;

import com.atguigu.srb.mybatis.pojo.User;
import com.atguigu.srb.mybatis.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author lsyandwh:
 * @create 2022-11-29 16:42
 */
@RestController
@RequestMapping("/user")
@CrossOrigin//解决跨域问题
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/list")
    public List<User> getUserList(HttpServletRequest request){

        String token = request.getHeader("token");
        System.out.println("token = " + token);

        return userService.list();
    }
}
